<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // ## 4. aabccd，去掉重复的字符，使结果显示 abcd
        //创建一个字符串
        var str = 'aabccd'
        //将字符串切割到数组里
        var arr = str.split('')
        console.log(arr)
        var res = arr.reduce(function(pre,cur){
            if(pre.indexOf(cur) === -1){
                return pre.concat(cur)
            }else{
                return pre
            }
        },[])
        console.log(res)
    </script>
</body>
</html>